﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="../../Scripts/easyUI/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../Scripts/easyUI/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/easyUI/jquery-1.8.0.min.js" type="text/javascript"></script>
    <script src="../../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/EasyUIUtility.js" type="text/javascript"></script>

    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../Gener.js" type="text/javascript"></script>

     <script language="javascript" type="text/javascript" >

        //定义公共个变量.
        var webUser = new WebUser();

        var ensName = GetQueryString("EnsName");

        //当前用户页面信息.
        var ur = new Entity("BP.Sys.UserRegedit");
        ur.MyPK = webUser.No + "_" + ensName + "_SearchAttrs";
        ur.RetrieveFromDBSources();

        var mapBase;
        var enName = null;
        var pkVal = null;

        //页面启动函数.
        $(function () {

            var httpHandler = new HttpHandler("BP.WF.HttpHandler.WF_CommEntity");
            var enName = GetQueryString("EnName");
            var pkVal = GetPKVal();

            if (enName == null) {
                enName = "BP.WF.Template.NodeExt";
                pkVal = "101";
            }

            httpHandler.AddPara("EnName", enName);

            if (pkVal != null) {
                httpHandler.AddPara("PKVal", pkVal);
            }

            var data = httpHandler.DoMethodReturnString("Entity_Init");
            if (data.indexOf('err@') == 0) {
                $("#CCForm").html(data);
                return;
            }

            //解析json.
            frmData = JSON.parse(data);
            mapData = frmData["Sys_MapData"][0];
            mapData = new Entity("BP.Sys.MapData", mapData); //把他转化成entity.
            mainData = frmData["MainData"];
            dtM = frmData["dtM"];

            document.title = mapData.Name;

            RefMethod(); //初始化菜单.

            $("#Msg").html("");

        });

        function RefMethod() {

            if (dtM.length == 0)
                return;

            //求出所有的分组名称.
            var groupName = "@基本信息";
            for (var i = 0; i < dtM.length; i++) {
                var en = dtM[i];
                if (en.GroupName == null)
                    continue;

                if (groupName.indexOf('@' + en.GroupName) == -1)
                    groupName += "@" + en.GroupName;
            }

            var gNames = groupName.split('@');

            //生成菜单.
            var html = "";
            for (var i = 0; i < gNames.length; i++) {
                var gName = gNames[i];
                if (gName == "")
                    continue;
                html += "<fieldset>";
                html += "<legend>"+gName+"</legend>";

                //填入菜单内容.
                html += "<ul >";

              

                for (var idx = 0; idx < dtM.length; idx++) {

                    var en = dtM[idx];
                    var myName = en.GroupName;
                    if (myName == null || myName == "")
                        myName = "基本信息";

                    if (gName != myName)
                        continue;

                    if (en.RefAttrKey != null || en.IsCanBatch == "1" || en.Visable == 0)
                        continue;

                    if (gName == "基本信息" && idx == 0) {
                        html += "<li style='float:left;margin:5px;list-style:none' >" + GenerRMBase() + "</li>";
                    }

                    html += "<li style='float:left;margin:5px;list-style:none' >" + GenerRM(en) + "</li>";
                }
                html += "</ul>";   //end填入菜单内容.

                html += "</fieldset>";
            }


            $("#docs").append(html);
            $.parser.parse("#docs");
        }

        function GenerRMBase() {

            if (enName == null) {
                enName = "BP.WF.Template.NodeExt";
                pkVal = "101";
            }

            var url = "EnOnly.htm?EnName=" + enName + "&PKVal=" + pkVal;
            var icon = "../../Img/dot.png";
            var html = "<a href=\"javascript:OpenIt('" + url + "', '基本信息',900,900)\" ><img src='" + icon + "' border=0 style='width:16px;height:16px;' />基本设置</a>";
            return html;
        }

        function GenerRM(rm) {

            var icon = rm.Icon;
            if (rm.Icon == "" || rm.Icon == null) {
                icon = "../../Img/dot.png";
            }

            if (rm.Icon != null && rm.Icon.indexOf('http') != 0) {
                icon = "../" + rm.Icon;
            }
            // alert('没有实现@代国强, 需要根据窗口大小，弹出模态窗口..');
            //var html = "<img src='" + icon + "' border=0 style='width:16px;height:16px;' /><a href='javascript:OpenIt(\"" + rm.Url + "\",\"" + rm.Title + "\",\"" + rm.W + "\",\"" + rm.H + "\")'>" + rm.Title + "</a>";
            var html = "<a href='javascript:OpenIt(\"" + rm.Url + "\",\"" + rm.Title + "\",\"" + rm.W + "\",\"" + rm.H + "\")'><img src='" + icon + "' border=0 style='width:16px;height:16px;' />" + rm.Title + "</a>";
            return html;
        }

        function OpenIt(url) {

            window.location.href = url; //  window.location.href;
        

            OpenEasyUiDialog(url, "eudlgframe", "详细", 800, 600, "icon-edit", true, null, null, null, function () {
                //  window.location.href = window.location.href;
            });
        } 
        </script>
</head>

<style>

legend
{
     font-size:medium;
}
</style>
<body>
<!--
<div id="bar" name="bar"  ><a href="">简洁模式</a>|<a href="">高级模式</a> <div style=" float:right">设置</div></div>-->

<div id="docs" name="docs" ></div>

</body>
</html>
